﻿@namespace Blazorise
@inherits BaseComponent
@using Blazorise.Extensions

<CascadingValue Value="@this" IsFixed>
    @if ( !modalInstances.IsNullOrEmpty() )
    {
        @foreach ( var modal in modalInstances )
        {
            <Modal @key="modal.ModalId" @ref="modal.ModalRef" @bind-Visible="modal.Visible" Attributes="@modal.Attributes" Animated="@modal.Animated" AnimationDuration="@modal.AnimationDuration" Background="@modal.Background" Border="@modal.Border" Casing="@modal.Casing" Class="@modal.Class"
                   Closed="() => OnModalClosed(modal)" Closing="@modal.Closing" Clearfix="@modal.Clearfix" ElementId="@modal.ModalId" Display="@modal.Display" Flex="@Flex" Float="@modal.Float" FocusTrap="@modal.FocusTrap" Height="@modal.Height" Margin="@modal.Margin"
                   Opened="@modal.Opened" Opening="@modal.Opening" Overflow="@modal.Overflow" Padding="@modal.Padding" Position="@modal.Position" RenderMode="@modal.RenderMode" ScrollToTop="@modal.ScrollToTop" Shadow="@modal.Shadow"
                   ShowBackdrop="@modal.ShowBackdrop" Style="@modal.Style" TextAlignment="@modal.TextAlignment" TextColor="@modal.TextColor" TextOverflow="@modal.TextOverflow" TextTransform="@modal.TextTransform" TextWeight="@modal.TextWeight"
                   VerticalAlignment="@modal.VerticalAlignment" Width="@modal.Width" Visibility="@modal.Visibility">
                <ModalContent Size="@modal.Size" Centered="@modal.Centered" Scrollable="@modal.Scrollable">
                    @if ( modal.UseModalStructure )
                    {
                        <ModalHeader>
                            @if ( !string.IsNullOrWhiteSpace( modal.Title ) )
                            {
                                <ModalTitle>
                                    @modal.Title
                                </ModalTitle>
                            }
                            <CloseButton />
                        </ModalHeader>
                        <ModalBody>
                            @modal.ChildContent
                        </ModalBody>
                    }
                    else
                    {
                        @modal.ChildContent
                    }
                </ModalContent>
            </Modal>
        }
    }
</CascadingValue>